Skip to content

Fix XYB conversion#463

Merged
facelessuser merged 1 commit intomainfrom
bugfix/xyb
Mar 19, 2025
Merged

Fix XYB conversion#463
facelessuser merged 1 commit intomainfrom
bugfix/xyb

Conversation

@facelessuser
Copy link
Copy Markdown
Owner

The default form of XYB has X = B = 0 for achromatic colors. This was done by altering the XYB transform matrix to do the LMS to XYB conversion and apply B - Y, but we had done so incorrectly. The matrix that incorporates this change should have been:

XYB_LMS_TO_XYB = [
[0.5, -0.5, 0.0],
[0.5, 0.5, 0.0],
[-0.5, -0.5, 1.0]
]

We mistakenly applied the logic in reverse applying to the forward transform which should have been in the inverse transform and vice versa. It resulted in the same X = B = 0, but non achromatic colors were not quite right.

With all of that said, instead of using a clever matrix to do the XYB transform and subtract Y from B, we now use the standard matrix and then just subtract Y from B at the end. We verified both were equivalent, but the later approach makes it more clear what we are doing.

The default form of XYB has X = B = 0 for achromatic colors. This was
done by altering the XYB transform matrix to do the LMS to XYB
conversion and apply B - Y, but we had done so incorrectly. The matrix
that incorporates this change should have been:

XYB_LMS_TO_XYB = [
    [0.5, -0.5, 0.0],
    [0.5, 0.5, 0.0],
    [-0.5, -0.5, 1.0]
]

We mistakenly applied the logic in reverse applying to the forward
transform which should have been in the inverse transform and vice
versa. It resulted in the same X = B = 0, but non achromatic colors
were not quite right.

With all of that said, instead of using a clever matrix to do the XYB
transform and subtract Y from B, we now use the standard matrix and then
just subtract Y from B at the end. We verified both were equivalent, but
the later approach makes it more clear what we are doing.
@gir-bot gir-bot added S: needs-review Needs to be reviewed and/or approved. C: docs Related to documentation. C: infrastructure Related to project infrastructure. C: source Related to source code. C: tests Related to testing. labels Mar 19, 2025
@facelessuser
Copy link
Copy Markdown
Owner Author

@gir-bot lgtm

@gir-bot gir-bot added S: approved The pull request is ready to be merged. and removed S: needs-review Needs to be reviewed and/or approved. labels Mar 19, 2025
@facelessuser facelessuser merged commit e30e65f into main Mar 19, 2025
16 checks passed
@facelessuser facelessuser deleted the bugfix/xyb branch March 19, 2025 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C: docs Related to documentation. C: infrastructure Related to project infrastructure. C: source Related to source code. C: tests Related to testing. S: approved The pull request is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants